package com.xuecheng.content.api;

import com.xuecheng.content.mapper.TeachplanMapper;
import com.xuecheng.content.model.dto.BindTeachplanMediaDto;
import com.xuecheng.content.model.dto.SaveTeachplanDto;
import com.xuecheng.content.model.dto.TeachplanDto;
import com.xuecheng.content.service.TeachplanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description: 课程计划编辑接口 
 * @params:        
 * @return: 
 * @author: ajie
 * @date: 2024/1/14 10:12
 */
@Api(value = "课程计划编辑接口",tags = "课程计划编辑接口")
 @RestController
public class TeachplanController {

    @Autowired
    TeachplanService teachplanService;

    /**
     * @description: 查询课程计划树形结构
     * @params: [courseId]       
     * @return:
     * @author: ajie
     * @date: 2024/1/14 10:17
     */
    @ApiOperation("查询课程计划树形结构")
    @ApiImplicitParam(value = "courseId",name = "课程Id",required = true,dataType = "Long",paramType = "path")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachplanDto> getTreeNodes(@PathVariable Long courseId){
        return teachplanService.findTeachplanTree(courseId);
    }

    /**
     * @description: 课程计划创建或修改
     * @params: [teachplan]       
     * @return: 
     * @author: ajie
     * @date: 2024/1/14 16:35
     */
    @ApiOperation("课程计划创建或修改")
    @PostMapping("/teachplan")
    public void saveTeachplan( @RequestBody SaveTeachplanDto saveTeachplanDto){
        teachplanService.saveTeachplan(saveTeachplanDto);

    }

    /**
     * @description: 删除课程计划
     * @params: [teachplanId]
     * @return:
     * @author: ajie
     * @date: 2024/1/14 21:18
     */
    @ApiOperation("删除课程计划")
    @DeleteMapping("/teachplan/{teachplanId}")
    public void deleteTeachplan(@PathVariable Long teachplanId){
        teachplanService.deleteTeachplanById(teachplanId);

    }

    /**
     * @description: 课程计划向下移动
     * @params: [id]
     * @return:
     * @author: ajie
     * @date: 2024/1/15 20:16
     */
    @ApiOperation("课程计划向下移动")
    @PostMapping("/teachplan/movedown/{id}")
    public void movedownTeachplan(@PathVariable Long id){
        teachplanService.movedownTeachplan(id);

    }

    /**
     * @description: 课程计划向上移动
     * @params: [id]
     * @return:
     * @author: ajie
     * @date: 2024/1/15 22:10
     */
    @ApiOperation("课程计划向上移动")
    @PostMapping("/teachplan//moveup/{id}")
    public void moveupTeachplan(@PathVariable Long id){
        teachplanService.moveupTeachplan(id);

    }

    /**
     * @description: 课程计划和媒资信息绑定
     * @params: [bindTeachplanMediaDto]       
     * @return: 
     * @author: ajie
     * @date: 2024/1/24 21:24
     */
    @ApiOperation(value = "课程计划和媒资信息绑定")
    @PostMapping("/teachplan/association/media")
    public void associationMedia(@RequestBody BindTeachplanMediaDto bindTeachplanMediaDto){
        teachplanService.associationMedia(bindTeachplanMediaDto);

    }

    /**
     * @description: 课程计划和媒资信息绑定 
     * @params: [teachPlanId, mediaId]       
     * @return:
     * @author: ajie
     * @date: 2024/1/24 22:06
     */
    @ApiOperation("解除课程计划和媒资信息绑定")
    @DeleteMapping("/teachplan/association/media/{teachPlanId}/{mediaId}")
    public void deleteAssociationMedia(@PathVariable Long teachPlanId,@PathVariable String mediaId){
        teachplanService.deleteAssociationMedia(teachPlanId,mediaId);
    }



}
